<template>
  <view class="container-flex" >
    <view class="station-section" v-if="stationList.length">
      <view class="station-list">
        <view 
          v-for="(station, index) in stationList" 
          :key="index" 
          class="station-card"
          @click="navigateTo(station.detailPath)"
        >
		 <image :src="station.img" mode="widthFix" style="width: 100px;border-radius: 6px;"></image>
          <view class="flex-right">
          	<view class="flex-right-text">
          		<text class="station-title">{{ station.name }}</text>
          		<text class="station-rate">{{ station.address }}</text>
          	</view>
          	<view class="tags">
          	  <text v-for="(tag, tagIndex) in station.tags" :key="tagIndex" class="tag">{{ tag }}</text>
          	</view>
          </view>
        </view>
      </view>
    </view>
	<u-loading-page loading-text="加载中..." :loading="loading"></u-loading-page>
  </view>
</template>

<script>
  const db = uniCloud.database();
  const pageDb=uniCloud.importObject('mydb-page')
export default {
  data() {
    return {
      primaryColor: '#007AFF',
      stationList: [],
	  loading:true
    }
  },
  onLoad() {
    // 设置主题色
    uni.setNavigationBarColor({
      frontColor: '#ffffff',
      backgroundColor: this.primaryColor
    })
	pageDb.getNetList().then((res)=>{
		this.stationList=res.data
		this.loading=false
	})
  },
  methods: {
    navigateTo(path) {
      uni.navigateTo({
        url: path
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.container-flex {
  
}
.quick-apply,
.station-section,
.news-section {
  background-color: #fff;
  margin: 0 30rpx 30rpx;
  border-radius: 16rpx;

  .section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30rpx;

    .title {
      font-size: 32rpx;
      font-weight: bold;
      color: #333;
    }

    .more {
      font-size: 24rpx;
      color: #007AFF;
    }
  }
}


.station-list {
  display: flex;
  flex-direction: column;
  gap: 20rpx;

  .station-card {
    background-color: #f9f9f9;
    padding: 30rpx;
    border-radius: 16rpx;
	display: flex;
	justify-content: space-between;
	align-items: center;
	.flex-right{
		width: 64%;
		padding-left: 15px;
		display: flex;
		align-items: flex-start;
		flex-direction: column;
		.flex-right-text{
			display: flex;
			text-align: left;
			flex-direction: column;
			padding-bottom: 10px;
		}
	}
    .station-title {
      font-size: 32rpx;
      font-weight: bold;
      color: #ff3b30;
      margin-bottom: 10rpx
    }

    .station-desc {
      font-size: 24rpx;
      color: #666;
    }

    .station-rate {
      display: block;
      font-size: 24rpx;
      color: #333;
      font-weight: bold;
    }

    .tags {
      display: flex;
      flex-wrap: wrap;
      gap: 10rpx;

      .tag {
        background-color: #e6f2ff;
        color: #007AFF;
        font-size: 20rpx;
        padding: 6rpx 16rpx;
        border-radius: 20rpx;
      }
    }
  }
}

</style>